#include "student.h"
#include "logger.h"
#include <ostream>
#include <cstdlib>
using namespace std;

Student::Student( int studentID, const string& first, const string& last)
    :studentID(studentID), firstName(first), lastName(last), courseCount(0)
{
	
}
Student::Student() :
    courseCount(0)
{
    Student(-1, "", "");
}

Student::~Student()
{
}

Schedule Student::getCurrSchedule() const
{
	return currentSched;
}

//Schedule Student::getSchedule(int timePeriod){} //Later feature
vector< boost::shared_ptr<Course> > Student::getCompletedCourses() const
{
	return completedCourses; // walkaround compile error;  function is a stub
}

bool Student::isTaken(Course * queryCourse) const
{
	return false; // walkaround compile error;  function is a stub
}

bool Student::isRequired(Course * queryCourse) const
{
	return false; // walkaround compile error;  function is a stub
}

//	void Student::archiveSchedule(){} // Later Feature
void Student::addCompletedCourse(boost::shared_ptr<Course> course)
{
	completedCourses.push_back(course);
}

/**
   Return true on success.
 */
bool Student::setFirstName( const string & name )
{
    firstName = name;
    return true;
}


/**
   Return true on success.
 */
bool Student::setLastName( const string & name )
{
    lastName = name;
    return true;
}


/**
   Return true on success.
 */
bool Student::setStudentID( const string& id )
{
    return setStudentID( atoi( id.c_str() )  );
}

bool Student::setStudentID( int id )
{
    studentID = id;
    return true;
}

bool Student::setPassword( const std::string& pass)
{
    passHash = pass;
    return true;
}

bool Student::setCurriculumFile( const std::string& curr )
{
	curriculumFile = curr;
	return true;
}

void Student::setConstraints(boost::shared_ptr<Constraint> newConstraints)
{
    constraints = newConstraints;
}

void Student::setCourseCount(std::size_t newCourseCount)
{
    courseCount = newCourseCount;
}

string Student::getCurriculumFile() const
{
	return curriculumFile;
}

std::string Student::getFirstName () const
{
    return firstName;
}

std::string Student::getLastName () const
{
	return lastName;
}

int Student::getStudentID () const
{
	return studentID;
}

boost::shared_ptr<Constraint> Student::getConstraints() const
{
    return constraints;
}

std::size_t Student::getCourseCount() const
{
    return courseCount;
}

bool Student::isCorrectPassword( const std::string& pass ) const
{
    //check password
    Logger::instance()->warning("isCorrectPassword INVOKED NOT DEFINED YET ALWAYS RETURNS TRUE, DO NOT USE!!!!!!", 1);

    return true;
}

ostream& operator<<(ostream& output, const Student& s)
{
	return output << s.getFirstName() << " " << s.getLastName() << " [" << s.getStudentID() << "]";
}
